Completed
Push — master ( 3b8b0c...578b04 )
by Michael
02:39
created

CodeMenuItemDispatcher.js ➔ isAvailable   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
import AbstractMenuItemDispatcher from './AbstractMenuItemDispatcher';
2
import { svgIcon } from '../MDI';
3
import { setBlockTypeNoAttrCheck } from '../../../customCommands';
4
import MenuItem from '../MenuItem';
5
6
export default class CodeMenuItemDispatcher extends AbstractMenuItemDispatcher {
7
    static isAvailable(schema) {
8
        return !!schema.nodes.code_block;
9
    }
10
11
    static getMenuItem(schema) {
12
        if (!this.isAvailable(schema)) {
13
            throw new Error('Code blocks not available in this Schmea!');
14
        }
15
        return new MenuItem({
16
            command: setBlockTypeNoAttrCheck(schema.nodes.code_block),
17
            icon: svgIcon('code-braces'),
18
            label: 'Code Block',
19
        });
20
    }
21
}
22